﻿@using SCMS.Resource
@model SCMS.UI.Models.AdvanceRequestModel
@{AjaxOptions ajaxOpts = new AjaxOptions
{
    UpdateTargetId = "R4ADiv",
    LoadingElementId = "loading",
    HttpMethod = "Post",
    Url = Url.Action("LoadRFADetails2/" + Model.Id)
};} 
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Model.RefNumber</h3></div>
    <br />
    <table width="98%" align="center" border="0" cellpadding="2" cellspacing="2" style=" border-bottom: 1px solid Grey;">
        <tr class="gridheader">
            <td colspan="3">
                @Resources.Global_String_SubjectPurpose
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <b>@Model.Subject</b>
                @Html.HiddenFor(x => x.Subject)
            </td>
        </tr>
        <tr class="gridheader">
            <td>
                @Resources.Request4Advance_CreateRFA_PaymentTo
            </td>
            <td>
                @Resources.Global_String_PaymentTerms
            </td>
            <td>
                @Resources.Global_String_PaymentType
            </td>
        </tr>
        <tr>
            <td align="center">
                @Model.Payee
            </td>
            <td align="center">
                @Model.PaymentTerm
            </td>
            <td align="center">
                @Model.PaymentType
            </td>
        </tr>
        <tr class="gridheader">
            <td width="33%">
                @Resources.Global_String_Date
            </td>
            <td width="33%">
                @Resources.Global_String_Currency
            </td>
            <td width="34%">
                @Resources.Global_String_TotalPayment
            </td>
        </tr>
        <tr>
            <td align="center">
                @Model.RequestDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.Currency
                @Html.HiddenFor(x => x.CurrencyId, new { @id = "currencyId"})
            </td>
            <td align="center">
                <b>@Model.TotalAdvance.ToString("#,##0.00")</b>
                @Html.HiddenFor(m => m.TotalAdvance, new { @id = "totalAdvance"})
            </td>
        </tr>
    </table>
    <br />    
        
    <table class="cardTable" cellpadding="2">
        <tr class="gridheader">
            <th colspan="6" align="center">@Resources.Global_String_PaymentDetails</th>
        </tr>
        <tr>
            <td colspan="6">
                @Ajax.ActionLink(Resources.Request4Advance_LoadRFADetails_AddPaymentDetail, "CreateRFADetail", new AjaxOptions
                {
                    UpdateTargetId = "popup-page",
                    LoadingElementId = "popup-loading",
                    Url = Url.Action("CreateRFADetail/" + Model.Id),
                    OnBegin = string.Format("ShowDialogue('{0}')", Resources.Request4Advance_LoadRFADetails_AddPaymentDetail),
                    OnSuccess = "CenterPopup();ClearForm();"
                })
            </td>
        </tr>
        @if (Model.PaymentDetails.Count > 0)
        { 
            <tr class="gridheader">
                <th align="center">@Resources.Request4Advance_CreateRFADetail_RequestFor</th>
                <th align="center">@Resources.Global_String_Description</th>
                <th align="center">@Resources.Budget_CategoryList_ProjectNo</th>
                <th align="center">@Resources.Budget_CreateSubLine_LineNumber</th>
                <th align="center">@Resources.Global_String_Amount</th>
                <th align="center">@Resources.Global_String_Manage</th>
            </tr>
            foreach (var detail in Model.PaymentDetails)
            { 
                <tr>
                    <td>@detail.AdvanceOption</td>
                    <td>@detail.Description</td>
                    <td>@detail.ProjectNo</td>
                    <td>@detail.BudgetLine</td>
                    <td align="right">@detail.Amount.ToString("#,##0.00")</td>
                    <td>
                        @Ajax.ActionLink(Resources.Global_String_Edit, "EditRFADetail", new { id = "EditRFADetail" }, new AjaxOptions
                        {
                            UpdateTargetId = "popup-page",
                            LoadingElementId = "popup-loading",
                            Url = Url.Action("EditRFADetail/" + detail.Id),
                            OnBegin = string.Format("ShowDialogue('{0}:: " + detail.AdvanceOption + "')", Resources.Global_String_Edit),
                            OnSuccess = "clenaRFANumbers"
                        })
                        &nbsp; | &nbsp;
                        @Ajax.ActionLink(Resources.Global_String_Remove, "DeleteRFADetail", new { id = "DeleteRFADetail" }, new AjaxOptions
                        {
                            UpdateTargetId = "R4ADiv",
                            LoadingElementId = "loading",
                            Url = Url.Action("DeleteRFADetail/" + detail.Id),
                            Confirm = Resources.Request4Advance_LoadRFADetails_ConfirmRemove
                        })
                    </td>
                </tr>
            }
        }
    </table>
    @if (Model.BudgetCheckResults != null && Model.BudgetCheckResults.Count > 0)
    {
        <br />
        <center style="text-align: center; color: Red; font-weight: bold; font-style: italic;">@Resources_frank.RequestForAdvance_LoadRFADetails_FundsUnavailableMessage</center>
        <table align="center" class="cardTable">
            <tr>
                <th>@Resources.Budget_CategoryList_ProjectNo</th>
                <th>@Resources.Budget_CreateSubLine_LineNumber</th>
                <th>@Resources.MasterBudget_MasterBudget_FundsAvailable</th>
                <th>@Resources_frank.RequestReview_ReviewRFP_RequestAmount</th>
            </tr>
            @foreach (var bcr in Model.BudgetCheckResults)
            {
                <tr>
                    <td>@bcr.ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber</td>
                    <td>@bcr.ProjectBudget.LineNumber @bcr.ProjectBudget.Description</td>
                    <td style="color: Red; font-weight: bold;" align="right">@bcr.AvailableAmount.ToString("#,##0.00")</td>
                    <td align="right">@bcr.AmountChecked.ToString("#,##0.00")</td>
                </tr>
            }
        </table>
    }
    <br /> 
    <table width="98%" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td width="50%"><input type="button" class="btn green" value="<< @Resources.Global_String_Prev" onclick="sendRequest('/Request4Advance/EditRFA/@Model.Id', 'R4ADiv', 'loading')" /></td>
            <td width="50%" align="right"><input type="button" class="btn green" value="@Resources.Global_String_Next >>" onclick="checkRFADetails('/Request4Advance/LoadRFADetails2/@Model.Id', 'R4ADiv', 'loading')" /></td>
        </tr>
    </table>  
</div>

